// 1折线图
const lineChart= () =>{
    let myChart =echarts.init(document.querySelector('#line'))
    let option ={
        title:{
           text:'2020全学科薪资走势',
        top:'15',
        left:'10',
        textStyle:{
            fontSize:16
        }},
        xAxis: {
            type: 'category',
            data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
          },
          axisLabel:{
           color:'#999'
          },
          axisLine:{
            lineStyle:'#ccc',
            type:'dashed'
          },
          yAxis: {
            type: 'value',
            splitLine:{
                lineStyle:{
                    type:'dashed'
                }
            }
          },
          series: [
            {
              data: [9000, 12000, 15000, 13000, 10000, 18000, 14000, 10000, 12000, 13000, 15000, 19000],
              type: 'line',
              smooth: true,
              lineStyle:{
                width:6,
              },
              symbolSize:10,
              areaStyle:{
                color:{
                  type: 'linear',
                  x: 0,
                  y: 0,
                  x2: 0,
                  y2: 1,
                  colorStops:[
                    {offset:0,color:'#499FEE'},
                    {offset:0.8,color:'rgba(255,255,255,0.2)'},
                    {offset:1,color:'rgba(255,255,255,0)'}
                  ],
                  global: false 
                }
              }
            }
          ],
          tooltip:{
            trigger: 'axis' 
          },
          grid:{
            top:'20%'
          },
          color: ['#499FEE', {
            type: 'linear',
            x: 0,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [{
              offset: 0, color: '#499FEE' 
            }, {
              offset: 1, color: '#5D75F0' 
            }],
            global: false 
          }
            ]
    }
    myChart.setOption(option)
}
lineChart()
// 饼图 右上角
const classSalaryChart =()=>{
 const myChart =echarts.init(document.querySelector('#salary'))
 const option ={
  title:{
    text: '班级薪资分布',
      left: 10,
      top: 15,
      textStyle: {
        fontSize: 16
      }
  },
  tooltip: {
    trigger: 'item'
  },
  legend: {
   bottom: '6%',
    left: 'center'
  },
  color: ['#FDA224', '#5097FF', '#3ABCFA', '#34D39A'],
  series: [
    {
      name: '班级薪资分布',
      type: 'pie',
      radius: ['50%', '64%'],
      // avoidLabelOverlap: false,
      itemStyle: {
        borderRadius: 10,
        borderColor: '#fff',
        borderWidth: 2
      },
      label: {
        show: false,
        position: 'center'
      },
      // emphasis: {
      //   label: {
      //     show: true,
      //     fontSize: '40',
      //     fontWeight: 'bold'
      //   }
      // },
      labelLine: {
        show: false
      },
      data: [
       { value: 1048, name: '1万以下' },
  { value: 235, name: '1万-2万' },
  { value: 580, name: '1.5万-2万' },
  { value: 484, name: '2万以上' }
      ]
    }
  ]
 }
 myChart.setOption(option)
}
classSalaryChart()
// 饼图 左下角

const sexSalaryChart = () => {
  const myChart = echarts.init(document.querySelector('#gender'))
  const option = {
    title: [
      {
        text: '男女薪资分布',
        left: 10,
        top: 10,
        textStyle: {
          fontSize: 16
        }
      },
      {
        text: '男生',
        left: '45%', 
        top: '45%',
        textStyle: {
          fontSize: 12
        }
      },
      {
        text: '女生',
        left: '45%',
        top: '85%',
        textStyle: {
          fontSize: 12
        }
      }
    ],
    tooltip: {
      trigger: 'item'
    },
    color: ['#FDA224', '#5097FF', '#3ABCFA', '#34D39A'],
    series: [
      {
        name: '男生薪资分布',
        type: 'pie',
        radius: ['20%', '30%'],
        center:['50%', '30%'],
        data: [
         { value: 1048, name: '1万以下' },
        { value: 235, name: '1万-2万' },
       { value: 580, name: '1.5万-2万' },
      { value: 484, name: '2万以上' }
        ]
      },
      {
        name: '女生薪资分布',
        type: 'pie',
        radius: ['20%', '30%'],
        center:['50%', '70%'],
        data: [
         { value: 1048, name: '1万以下' },
        { value: 235, name: '1万-2万' },
       { value: 580, name: '1.5万-2万' },
      { value: 484, name: '2万以上' }
        ]
      }
    ]
  }
  myChart.setOption(option)
}
sexSalaryChart()
// 柱状图 

const groupSalaryChart = () => {
  const myChart = echarts.init(document.querySelector('#lines'))
  const option = {
    xAxis:{
      type:'category',
      data: ['小张', '小明', '小红', '小刘', '小马', '小岳', '小徐', '小朱'],
      axisLabel:{
        color:'#999'
      },
      axisLine:{
        lineStyle:{
          color:'#ccc',
          type:'dashed'
        }
      }
    },
    yAxis:{
      type:'value',
      splitLine:{
        lineStyle:{
          type:'dashed'
        }
      }
    },
    series: [
      {
        data: [12200, 17932, 13901, 13934, 21290, 23300, 13300, 13320],
        type: 'bar',
        name: '期望薪资'
      },
      {
        data: [22820, 19932, 16901, 15934, 31290, 13300, 14300, 18320],
        type: 'bar',
        name: '实际薪资'
      }
    ],
    tooltip: {},
    color: [
      {
        type: 'linear',
        x: 0,
        y: 0,
        x2: 0,
        y2: 1,
        colorStops: [
          {
            offset: 0,
            color: '#34D39A' 
          },
          {
            offset: 1,
            color: 'rgba(52,211,154,0.2)' 
          }
        ],
        global: false 
      },
      {
        type: 'linear',
        x: 0,
        y: 0,
        x2: 0,
        y2: 1,
        colorStops: [
          {
            offset: 0,
            color: '#499FEE' 
          },
          {
            offset: 1,
            color: 'rgba(73,159,238,0.2)' 
          }
        ],
        global: false 
      }
    ],
    grid: {
      top: 30,
      bottom: 50,
      left: 70,
      right: 30
    }
  }
  myChart.setOption(option)
}
groupSalaryChart()
// 地图
const mapChart = () => {
  const mapData = [
    // 数据的 name 必须要和 地图的名字一致
    { name: '南海诸岛', value: 0 },
    { name: '北京', value: 3 },
    { name: '天津', value: 2 },
    { name: '上海', value: 4 },
    { name: '重庆', value: 1 },
    { name: '河北', value: 20 },
    { name: '河南', value: 23 },
    { name: '云南', value: 0 },
    { name: '辽宁', value: 15 },
    { name: '黑龙江', value: 12 },
    { name: '湖南', value: 2 },
    { name: '安徽', value: 5 },
    { name: '山东', value: 18 },
    { name: '新疆', value: 0 },
    { name: '江苏', value: 5 },
    { name: '浙江', value: 1 },
    { name: '江西', value: 4 },
    { name: '湖北', value: 3 },
    { name: '广西', value: 2 },
    { name: '甘肃', value: 9 },
    { name: '山西', value: 11 },
    { name: '内蒙古', value: 14 },
    { name: '陕西', value: 14 },
    { name: '吉林', value: 10 },
    { name: '福建', value: 0 },
    { name: '贵州', value: 0 },
    { name: '广东', value: 0 },
    { name: '青海', value: 3 },
    { name: '西藏', value: 0 },
    { name: '四川', value: 1 },
    { name: '宁夏', value: 1 },
    { name: '海南', value: 0 },
    { name: '台湾', value: 0 },
    { name: '香港', value: 0 },
    { name: '澳门', value: 0 }
  ]
  const myChart = echarts.init(document.querySelector('#map'))
  const option = {
    title:{
      text: '籍贯分布',
      left: 10,
      top: 10,
      textStyle: {
        fontSize: 16
      }
    },
    series: [
      {
        name: '籍贯分布',
        data: mapData,
        type: 'map', 
        map: 'china',
        label: {
          show: true, 
          fontSize: 10,
          color: 'rgba(0,0,0,0.7)'
        },
        itemStyle: {
          areaColor: '#E0FFFF',
          borderColor: 'rgba(0, 0, 0, 0.2)', 
        },
        emphasis: {
          itemStyle: {
            areaColor: '#34D39A',
            borderWidth: 0,
            shadowBlur: 20,
            shadowOffsetX: 0,
            shadowOffsetY: 0,
            shadowColor: 'rgba(0, 0, 0, 0.5)'
          }
        }
      }
    ],
    visualMap: {
      type: 'continuous', 
      min: 0,
      max: 20,
      inRange: {
        color: ['#fff', '#0075F0']
      },
      text: [20, 0],
      left: 40,
      bottom: 20
    },
    tooltip: {
      formatter: '{b}：{c}位学员',
      textStyle: {
        color: '#fff'
      },
      borderColor: 'transparent', 
      backgroundColor: 'rgba(0, 0, 0, 0.5)'
    }
  }
  myChart.setOption(option)
}
mapChart()
